
PWD = $(shell pwd)
# INSTPATH = /usr/bin
export CFLAGS += -I${PWD}

DIR_COM = ../common/
DIR_LIB = ../lib/
DIR_ETC = ../etc/

CC=gcc

CFLAGS += -g -Wall -I$(DIR_COM) -I$(DIR_LIB) -I$(DIR_ETC)
LDFLAGS += -L$(DIR_COM) -L$(DIR_LIB) -L$(DIR_ETC) -L /home/iot22/zlog-1.2.15/src/ -L /home/iot22/sqlite3_build/lib/

LIBS = -lsqlite3 -lcjson -lzlog -lcommon -letc -llib -lpthread

TARGET = $(shell basename ${PWD})

CC = gcc

SRCS = ${PWD}/*.c 
SRCFILES = $(wildcard *.c)

all:clean modules binary

modules:${SRCFILES}
	make -C $(DIR_COM)
	make -C $(DIR_LIB)
	make -C $(DIR_ETC)

binary:
	$(CC) $(CFLAGS) ${SRCS} -o ${TARGET} $^ ${LDFLAGS} ${LIBS}

run:
	./${TARGET}

clean:
	rm -f ${TARGET}
	rm -f temper_server.db temper_server.log
	make clean -C $(DIR_COM)
	make clean -C $(DIR_LIB)
	make clean -C $(DIR_ETC)
